package GenericTest;

// T和E是类型占位符，分别代表两个类型
public class GenericClassForOrder<T, E> {

    private String orderTitle;

    private T ID;
    private T SubID;

    private E price;
    private E afterPrice;

    public GenericClassForOrder() {
    }

    public GenericClassForOrder(String orderTitle, T ID, T SubID, E price, E afterPrice) {
        this.orderTitle = orderTitle;
        this.ID = ID;
        this.SubID = SubID;
        this.price = price;
        this.afterPrice = afterPrice;
    }

    public T setID(T ID) {
        return this.ID = ID;
    }

    // 使用泛型方法
    public static void main(String[] args) {
        GenericClassForOrder<String, Integer> order1 = new GenericClassForOrder<>("Order1", "ID1", "SubID1", 100, 90);
        System.out.println(order1.orderTitle + " " + order1.ID + " " + order1.SubID + " " + order1.price + " "
                + order1.afterPrice);

        GenericClassForOrder<String, Double> order2 = new GenericClassForOrder<String, Double>("Order2", "ID2",
                "SubID2", 200.0, 180.0);
        System.out.println(order2.orderTitle + " " + order2.ID + " " + order2.SubID + " " + order2.price + " "
                + order2.afterPrice);
    }
}
